package com.gujiangbo.defrewlock;

/**
 * 读写锁接口
 */
public interface ReadWriteLock {

    //创建reader锁
    Lock readLock();

    //创建write锁
    Lock writeLock();

    //获取当前有多少个线程正在执行写操作
    int getWritingWriters();

    //获取当前有多少个线程正在等待获取写入锁
    int getWaitingWriters();

    //获取当前有多少个线程正在执行读操作
    int getReadingReaders();

    // 工厂方法，创建readWriteLock对象
    static ReadWriteLock readWriteLock() {
        return new ReadWriteLockImpl();
    }

    static ReadWriteLock readWriteLock(boolean perferWriter) {
        return new ReadWriteLockImpl(perferWriter);
    }
}
